<?php

use think\facade\Route;

/** 资讯管理后台路由 */
Route::group('admin', function () {
    Route::get('list', '@index'); // 点播列表数据
    Route::get('create', '@create'); // 创建资讯-页面
    Route::post('create', '@create'); // 创建资讯-提交
    // 单资讯 <id> 资讯ID
    Route::group('/<id>', function () {
        Route::get('edit$', '@update'); // 修改资讯-页面
        Route::put('edit$', '@update'); // 修改资讯-提交
        Route::put('edit/<field>$', '@editField');// 编辑某个字段
        Route::delete('$', '@delete'); // 删除资讯-软删除
    })->pattern(['id' => '\d+', 'field' => '[a-zA-Z_]+']);

    // 选择的资讯列表
    Route::get('choose/topicList', '@getTopicList');
    // 批量获取资讯详情
    Route::get('batch/info', '@getTopics');
    // 批量删除
    Route::delete('deletes/<ids>', '@deletes')->pattern(['ids' => '[\d,]+']);
})->prefix('\app\topic\service\admin\Topic')->middleware(['adminRoute']);

// 资讯分类
Route::group('admin/category', function () {
    Route::get('/list$', '@getList'); // 资讯分类列表
    Route::get('/<id>/children$', '@getChildren')->pattern(['id' => '\d+']); // 资讯分类列表
    Route::post('/create$', '@createCategory'); // 添加资讯分类
    Route::put('/<id>$', '@editCategory')->pattern(['id' => '\d+']); // 编辑资讯分类
    Route::delete('/<id>$', '@deleteCategory')->pattern(['id' => '\d+']); // 删除资讯分类
    Route::get('/cascader', '@getTree');// 树形结构

})->prefix('\app\common\service\category\admin\Category')->append(['category_type' => 5])->middleware(['adminRoute']);

/** 后台管理 */
Route::group('admin/comment/<topic_id>', function () {
    // 课程评论列表
    Route::get('list', '@commentList');
    Route::delete('<comment_id>/delete', '@deleteComment')->pattern(['comment_id' => '\d+']);
})
    ->prefix('\app\topic\service\admin\TopicComment')
    ->middleware(['adminRoute'])
    ->pattern(['topic_id' => '\d+']);
